package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Scanner;

public class Test5 {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入用户名");
        String username = sc.next();
        System.out.println("输入年龄");
        int age = sc.nextInt();
        System.out.println("输入用网名");
        String nickname = sc.next();
        System.out.println("输入密码");
        String password = sc.next();
        User user = new User(username,age,nickname,password);

        FileOutputStream fos = new FileOutputStream(username+".obj");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(user);
        oos.close();
        System.out.println("写完");
        System.out.println(user.toString());

    }

}
